from codex import * import time import random #The only issue is sometimes with random #I could get the same color twice in a row. object_list = [ GREEN, PINK, PURPLE, BLUE, pics.HEART, pics.TSHIRT, pics.HAPPY, pics.PLANE, ] score = 0 tries = 5 #Directions display.print('If a color is shown, press Button A.') display.print('If a picture is shown, press Button B.') time.sleep(2) while tries > 0: #Stops the game after 5 tries my_image = random.choice(object_list) if type(my_image) == tuple: #Checks to see if object in list is a color display.fill(my_image) time.sleep(2) if buttons.was_pressed(BTN_A): score = score + 1 tries = tries - 1 elif buttons.was_pressed(BTN_B): if score > 0: #Keeps the score from going negative score = score - 1 tries = tries - 1 #Chooses one of the items in a list elif type(my_image) != tuple: display.show(my_image) time.sleep(2) if buttons.was_pressed(BTN_B): score = score + 1 tries = tries - 1 elif buttons.was_pressed(BTN_A): if score > 0: score = score - 1 tries = tries - 1 display.fill(BLACK) display.print('Game Over') display.print('Score is: ' + str(score))